
export abstract class Validator<ValueType={}> {
    public message!: string|React.ReactNode;
    public statusCode!: string;
    public option: Validation.IValidatorOptions;
    public value!: ValueType;
    public validateResult: boolean = false;
    public hasChanged: boolean = false;
    constructor(opt: Validation.IValidatorOptions) {
        this.option = opt;
    }
    public abstract validate(value:ValueType, opt?:any):boolean;
    public setValue(value: ValueType): void {
        this.value = value;
        this.hasChanged = value !== this.option.defaultValue;
    }
    public getValue(): ValueType {
        return this.value;
    }
    public error(message: Validation.TMessage<ValueType>, code: string): void {
        const messageText: any = message;
        this.message = messageText;
        this.statusCode = code;
    }
};